home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
comms
/
other
/
novia
/
src
/
novia_io_main.c
< prev
next >
Wrap
Text File
|
1999-12-06
|
25KB
|
848 lines
#include <exec/types.h>
#include <stdlib.h>
#include <exec/ports.h>
#include <exec/io.h>
#include <exec/tasks.h>
#include <exec/lists.h>
#include <pragma/exec_lib.h>
#include <pragma/dos_lib.h>
#include <pragma/intuition_lib.h>
#include <pragma/gadtools_lib.h>
#include <pragma/commodities_lib.h>
#include <libraries/commodities.h>
#include <novia/novia_UserList.h>
#include <novia/novia_PortData.h>
#include <novia/novia_config.h>
#include <novia/novia_vde.h>
#include <novia/novia_mail.h>
#include <novia/novia_subboard.h>
#include <novia/novia_types.h>
#include <novia/novia_misc.h>
#include <novia/novia_message.h>
#include <novia/novia_gui.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <string.h>
#include <stdio.h>
#include <intuition/intuition.h>
#include <rexx/storage.h>
#include <clib/rexxsyslib_protos.h>
#include <novia/novia_funcs.h>
#include <pragma/noviasys_lib.h>
//#define DEBUG
/* **** NOVIA_MAIN.C IMPORTS **** */
extern struct Task *MainTask;
extern struct MsgPort *GUIPort;
extern struct MsgPort *MainGUIPort;
extern struct MsgPort *main_eventport;
extern struct MsgPort *cxport;
extern struct MainPortConfig *mainportconfig;
extern struct List *client_list;
extern CxObj *broker;
/* **** PROTOTYPES **** */
ULONG Conread(char *string, char len,ULONG sigs);
ULONG WaitSig(ULONG bitmask);
BOOL SendMsg(MsgPort *port, APTR data, ULONG data_len, ULONG msg_type, ULONG cmd_type);
void WaitConnect();
struct EventMessage *SendEventMsg(MsgPort *toport, MsgPort *replyport, APTR data, ULONG msg_type);
LONG handleCxMsg(struct Message *msg);
void ioprintf(const char *string, ...);
/* **** SERIAL NETWORK PROTOTYPES **** */
extern BOOL SN_Open();
extern void SN_Close();
extern BOOL SN_CheckNetworkStatus();
extern LONG SN_Send(APTR data, ULONG len);
extern ULONG SN_Recv(char *string, char len, ULONG BreakBitMask);
extern void SN_HangingUP();
extern void SN_WaitConnect();
/* **** OTHER PROTOTYPES **** */
extern BOOL SendGUIMsg(LONG msgid,APTR data);
extern void ReturnGUIMsg(GUIMsg *msg);
extern void FreeGUIMsg(GUIMsg *msg);
/* ************************** */
#define PORTTYPE_MAIN 1
#define PORTTYPE_CLIENT 0
#define PRIORITY_TOOL_TYPE "CX_PRIORITY"
#define POP_ON_START_TOOL_TYPE "CX_POPUP"
#define POPKEY_TOOL_TYPE "CX_POPKEY"
#define POP_KEY_ID (86L) /* pop up identifier */
// LONG DisplayListcport(REG(a2) char **array,REG(a1) struct PortData *cport2)
ULONG Conread(char *string, char len, ULONG sigs)
{
struct Task *mytask = FindTask(NULL);
struct PortData *cport = (PortData *)mytask->tc_UserData;
ULONG sigmask = 0;
struct SerialNetwork *sn = cport->network.networkdata;
if (cport)
{
ULONG sb_ConPort=0;
char quit=FALSE;
*string=0;
sb_ConPort=1<<cport->ConPort->mp_SigBit;
if (cport->win && cport->MonitorOpen && !cport->ConReadSend)
{
cport->ConRead->io_Command=(UWORD)CMD_READ;
cport->ConRead->io_Length=1;
cport->ConRead->io_Data=(APTR)cport->ConBuf;
SendIO((IORequest *)cport->ConRead);
cport->ConReadSend=TRUE;
}
while (!cport->ProgramClose && cport->network.online && !quit)
{
if (cport->network.isopen && cport->network.can_read)
sigmask = SN_Recv(cport->network.ReadBuf, 1, sigs | sb_ConPort);
else
{
sigmask = WaitSig(sigs | sb_ConPort);
}
if (sb_ConPort & sigmask)
{
if (cport->MonitorOpen && cport->win && cport->ConReadSend)
{
if (CheckIO((IORequest *)cport->ConRead))
{
WaitIO((IORequest *)cport->ConRead);
if (cport->ConRead->io_Actual > 0)
{
*string=*((char *)cport->ConRead->io_Data);
quit=TRUE;
cport->ConReadSend=FALSE;
}
}
}
}
if (*cport->network.ReadBuf)
{
*string=*((char *)*cport->network.ReadBuf);
quit=TRUE;
}
if (sigs & sigmask)
quit=TRUE;
}
}
if (sigs & sigmask)
return sigmask;
else
return NULL;
}
/*****************************************************************************************
* This function is a instand of exec's Wait() call. Use this for novia-internal *
* message handling. *
*****************************************************************************************/
ULONG WaitSig(ULONG bitmask) // same as exec.library Wait()
{
struct Task *mytask = FindTask(NULL); // own-task-address
struct PortData *cport = (PortData *)mytask->tc_UserData; // PortData-structure
ULONG sigs = 0; // waitsig-mask
if (cport) // check value
{
struct message *incommingmsg;
struct RexxMsg *rexxmsg;
ULONG sb_ClientPort = 1 << cport->LocalPort->mp_SigBit; // sigbit of local Port
ULONG sb_GUIPort; // sigbit of Main GUIPort
ULONG sb_IDCMP; // sigbit of local Window-Port
ULONG sb_rexxport = 1 << cport->rexxport->mp_SigBit; // sigbit of local rexxport
ULONG sb_main_eventport = 0; // sigbit of Main eventport
ULONG sb_nfs_port = 1 << cport->nfs_port->mp_SigBit; // sigbit of nfs_port
ULONG sb_cxport = 0;
char buffer[200],
Quit=FALSE,
quit=FALSE,
porttype;
ULONG counter;
if (mytask == MainTask) // testing for mainport
{
porttype = PORTTYPE_MAIN;
sb_GUIPort = 1 << MainGUIPort->mp_SigBit;
sb_main_eventport = 1 << main_eventport->mp_SigBit;
if (cxport)
sb_cxport = 1 << cxport->mp_SigBit;
}
else
porttype = PORTTYPE_CLIENT;
if (cport->MonitorOpen)
sb_IDCMP=1<<cport->win->UserPort->mp_SigBit;
else
sb_IDCMP=0;
while (!Quit && ((cport->network.online)|cport->connect_seq) && !cport->ProgramClose)
{
sigs=bitmask|sb_ClientPort|sb_GUIPort|sb_IDCMP|sb_rexxport|sb_main_eventport|sb_nfs_port|sb_cxport;
sigs=Wait(sigs);
if (sb_rexxport & sigs)
{
DoRexxMsg((RexxMsg *)GetMsg(cport->rexxport));
}
/************** IDCMP Message Handling *********************************************************/
if ((sb_IDCMP & sigs) && cport->MonitorOpen)
{
struct MenuItem *item;
ULONG item_number;
ULONG menu_number;
ULONG menucode;
struct Message *msg=NULL;
struct IntuiMessage *imsg=NULL;
while((imsg = (struct IntuiMessage *)GetMsg(cport->win->UserPort)))
{
if (imsg->Class==IDCMP_MENUPICK)
{
menucode = imsg->Code;
item = ItemAddress(cport->win->MenuStrip, menucode);
menu_number= MENUNUM(menucode);
item_number=ITEMNUM(menucode);
if (porttype==PORTTYPE_MAIN)
{
switch(menu_number)
{
case 0: // Menu Project
switch(item_number)
{
case 0: // ->About
break;
case 2: // ->Lock Consule
break;
case 3: // ->Close Window
break;
case 5: // ->Restart BBS
break;
case 6: // ->Reset Server
break;
case 8: // ->Quit
cport->ProgramClose = TRUE;
cport->network.online = FALSE;
Quit=TRUE;
break;
}
break;
case 1: // Menu Services
switch(item_number)
{
case 0: // -> no calls
break;
case 1: // -> no anser
break;
}
break;
}
}
else
{
switch(menu_number)
{
case 0: // Menu Project
switch(item_number)
{
case 0: // ->About
break;
case 2: // ->Local Login
break;
case 4: // ->Close Window
Monitor_close();
break;
case 5: // ->Quit
break;
}
break;
case 1: // Menu Client
switch(item_number)
{
case 0: // -> offline
break;
case 1: // -> noanser
break;
case 2: // -> enter sysop chat
if (cport->SysopChat)
{
cport->SysopChat = FALSE;
}
else
{
char chatbuffer[10];
cport->SysopChat = TRUE;
ioprintf("c1---Sysop chatc7\n");
while (!cport->ProgramClose && cport->network.online && cport->SysopChat)
{
Conread(chatbuffer,1,0);
if (*chatbuffer == 13)
Writeio("\n",-1);
else
Writeio(chatbuffer,1);
}
ioprintf("\nc1---existing Sysop charc7\n");
}
break;
case 3: // -> hanging up
cport->network.online = FALSE;
break;
}
break;
}
}
}
ReplyMsg((struct Message *)imsg);
}
}
/************** MainEventPort Message Handling *********************************************************/
if ((sb_main_eventport & sigs) && (porttype==PORTTYPE_MAIN))
{
struct EventMessage *msg;
while ((msg=(EventMessage *)GetMsg(main_eventport)))
{
if (msg->msg.mn_ReplyPort==main_eventport)
{
FreeVec(msg);
}
else
{
switch (msg->msg_type)
{
case GUIMSG_REDRAW_REMINDERLIST:
SendGUIMsg(GUIMSG_REDRAW_REMINDERLIST, 0);
break;
}
ReplyMsg((Message *)msg);
}
}
}
/************** GUI Message Handling ******************************************************************/
if ((sb_GUIPort & sigs) && (porttype==PORTTYPE_MAIN))
{
struct GUIMsg *guimsg=NULL;
struct PortData *cport2;
while((guimsg=(GUIMsg *)GetMsg(MainGUIPort)))
{
cport2=guimsg->data;
switch (guimsg->cmdid)
{
case GUIMSG_CLOSE_MAINPORT:
guimsg->cmdid=GUIMSG_CLOSE_WAIT_FOR_CLOSE_CMD;
// cport->ProgramClose=TRUE;
ioprintf("System shutdown, from GraficsUserInterface\n");
cport->ProgramClose=TRUE;
cport->network.online=FALSE;
break;
case GUIMSG_REPLY:
FreeGUIMsg(guimsg);
break;
case GUIMSG_MPCONFIG_SAVE:
SaveMainPortConfig(mainportconfig);
break;
case GUIMSG_MPCONFIG_USE:
break;
case GUIMSG_CLIENT_NEW:
cport2=NewClientPort();
if (cport2)SendGUIMsg(GUIMSG_CLIENT_EDIT,cport2);
break;
case GUIMSG_CLIENT_EDIT:
if (cport2)SendGUIMsg(GUIMSG_CLIENT_EDIT,cport2);
break;
case GUIMSG_CLIENT_ONLINE:
if (cport2->PortStatus==PORT_STATUS_CLOSE)
{
cport2->PortStatus=PORT_STATUS_WAITLOAD;
Execute("run execute s:start_client",NULL,NULL);
}
break;
case GUIMSG_CLIENT_OFFLINE:
cport2->PortStatus=PORT_STATUS_OFFLINE;
SendMsg(cport2->LocalPort,0,0,MSG_PORT_OFFLINE,0);
SendGUIMsg(GUIMSG_CLIENT_CHANGE,cport2);
break;
case GUIMSG_CLIENT_UNLOAD:
cport2->PortStatus=PORT_STATUS_CLOSE;
SendMsg(cport2->LocalPort,0,0,MSG_PORT_CLOSE,0);
SendGUIMsg(GUIMSG_CLIENT_CHANGE,cport2);
break;
case GUIMSG_CLIENT_USE:
SendGUIMsg(GUIMSG_CLIENT_CHANGE,cport2);
break;
case GUIMSG_CLIENT_SAVE:
SaveClientList();
break;
case GUIMSG_CLIENT_CANCEL:
break;
case GUIMSG_CLIENT_TOFRONT:
SendMsg(cport2->LocalPort,0,0,MSG_PORT_TOFRONT,0);
break;
}
if (guimsg->cmdid!=GUIMSG_REPLY)ReturnGUIMsg(guimsg);
}
}
/************** Local-/Main Port Message Handling *********************************************************/
if (sb_ClientPort & sigs)
{
char *txtptr;
struct PortData *cport2;
struct PortData2 *clientport;
struct OnLineMessage *olm,
*newolm;
/***** LOCAL Port Message Handling *****/
if (porttype == PORTTYPE_CLIENT)
{
while ((incommingmsg = (message *)GetMsg(cport->LocalPort)))
{
if (incommingmsg->msg.mn_ReplyPort == cport->LocalPort)
{
switch (incommingmsg->msg_type)
{
case MSG_COMMAND:
switch (incommingmsg->cmd_type)
{
case CMD_WHO:
LF();
ioprintf("%s\n",incommingmsg->data);
break;
}
break;
}
if (incommingmsg->data_len)
FreeVec(incommingmsg->data);
FreeVec(incommingmsg);
}
else
{
switch (incommingmsg->msg_type)
{
case MSG_CHAT_BREAK:
ioprintf("chat break ***\n");
cport->ChatBreak=TRUE;
break;
case MSG_TEXT:
txtptr=(char *)incommingmsg->data;
ioprintf("c2%d\n",*txtptr);
break;
case MSG_COMMAND:
switch (incommingmsg->cmd_type)
{
case CMD_OLM:
olm=(OnLineMessage *)incommingmsg->data;
ioprintf("ON LINE MESSAGE\n");
switch (olm->OLM_type)
{
case OLM_TYPE_NORMAL:
ioprintf("ONLINE MESSAGE FROM: %d TO: %d\n:%s",olm->FromUser,olm->ToUser,olm->data);
break;
case OLM_TYPE_CHATACCEPT:
ioprintf("\nChat Request accept\n");
// OpenChatConnection(olm->FromUser);
break;
case OLM_TYPE_CHATREJECT:
ioprintf("\nChat Request reject\n");
break;
case OLM_TYPE_BROADCAST:
ioprintf("BROADAST MESSAGE FROM: %d\n:%s",olm->FromUser,olm->data);
break;
case OLM_TYPE_CHATREQUEST:
if ((newolm=AllocVec(sizeof(OnLineMessage),MEMF_ANY|MEMF_CLEAR)))
{
newolm->ToUser=olm->FromUser;
newolm->FromUser=cport->clientconfig.IDNumber;
ioprintf("olm->FromUser: %d, LocalUser: %d\n",olm->FromUser,cport->LocalUser.IDNumber);
ioprintf("ToUser: %d, FromUser: %d\n",newolm->ToUser,newolm->FromUser);
ioprintf("CHAT REQUEST FROM: %d TO: %d\n:%s\n",olm->FromUser,olm->ToUser,olm->data);
ioprintf("Do you like a little chat ?: ");
if (Yesno(TRUE,0))
{
newolm->OLM_type=OLM_TYPE_CHATACCEPT;
SendMsg(cport->MainPort,newolm,sizeof(OnLineMessage),MSG_COMMAND,CMD_OLM);
// OpenChatConnection(olm->FromUser);
}
else
{
newolm->OLM_type=OLM_TYPE_CHATREJECT;
SendMsg(cport->MainPort,newolm,sizeof(OnLineMessage),MSG_COMMAND,CMD_OLM);
}
}
break;
}
break;
case CMD_LOGOFF:
break;
case CMD_WHO:
LF();
ioprintf(incommingmsg->data);
break;
}
break;
case MSG_PORT_CLOSE:
cport->network.online = FALSE;
cport->ProgramClose = TRUE;
incommingmsg->msg_type = MSG_REPLY_PORTCLOSEOK;
ReplyMsg((Message *)incommingmsg);
break;
case MSG_PORT_TOFRONT:
if (!cport->MonitorOpen)
{
Monitor_open();
if (cport->win)
{
sb_IDCMP=1<<cport->win->UserPort->mp_SigBit;
sigs=sb_ClientPort|sb_GUIPort|sb_IDCMP|sb_rexxport;
}
}
if (cport->win)
{
ScreenToFront(cport->win->WScreen);
WindowToFront(cport->win);
}
break;
case MSG_PING:
break;
}
ReplyMsg((Message *)incommingmsg);
}
}
}
else /***** MAIN Port Message Handling *****/
{
while(incommingmsg=(message *)GetMsg(cport->LocalPort))
{
if (incommingmsg->msg.mn_ReplyPort == cport->LocalPort)
{
switch (incommingmsg->msg_type)
{
case MSG_REPLY_PORTCLOSEFAILAT:
ioprintf("c3Port close c7% failat.\n");
break;
case MSG_REPLY_PORTCLOSEOK:
ioprintf("c3Port c7% is closed now.\n");
break;
case MSG_REPLY_PORTCLOSED:
ioprintf("c3Port c7% is closed now. (WARNING: THIS IS A OLD V0.01.02 MESSAGE !!!)\n");
break;
case MSG_REPLY_PORTOFFLINE:
ioprintf("c3Port c7% is offline now.\n");
break;
}
if (incommingmsg->data_len)
FreeMsg(incommingmsg->data);
FreeMsg(incommingmsg);
}
else
{
switch (incommingmsg->msg_type)
{
case MSG_CHAT_BREAK:
if ((cport2=FindClient(incommingmsg->cmd_type)))
// SendMsg(cport2->LocalPort,0,0,MSG_CHAT_BREAK,0);
PutMsg(cport2->LocalPort,(Message *)incommingmsg);
break;
case MSG_TEXT:
if ((cport2=FindClient(incommingmsg->cmd_type)))
PutMsg(cport2->LocalPort,(Message *)incommingmsg);
break;
case MSG_COMMAND:
switch (incommingmsg->cmd_type)
{
case CMD_OLM:
ioprintf("olm->ToUser: %d\n",olm->ToUser);
break;
case CMD_WHO:
txtptr=AllocVec(1000,MEMF_ANY|MEMF_CLEAR);
incommingmsg->data=txtptr;
incommingmsg->data_len=1000;
sprintf(txtptr,"Port Username Logon Spd From Where \n");
txtptr=txtptr+strlen(txtptr);
sprintf(txtptr,"==== =================== ====== === =================== =============\n");
txtptr=txtptr+strlen(txtptr);
clientport=(PortData2 *)client_list->lh_Head;
while (clientport->port_node.ln_Succ)
{
cport2=clientport->port_address;
sprintf(buffer,"%4d %-19s %2d:%02d %3d %-19s %s\n",
cport2->clientconfig.IDNumber,
cport2->LocalUser.Handle,
cport2->LastLogin.hours,
cport2->LastLogin.mins,
cport2->CurrentCPS,
cport2->LocalUser.City,
cport2->Where);
strcpy(txtptr,buffer);
txtptr=txtptr+strlen(buffer);
clientport=(PortData2 *)clientport->port_node.ln_Succ;
}
break;
case CMD_LOGOFF:
break;
}
break;
case MSG_INITPORT:
break;
case MSG_PORT_CHANGE: /* PORT-STATUS CHANGED */
// SendGUIMsg(GUIMSG_CLIENT_CHANGE,incommingmsg->data);
cport2=(PortData *)incommingmsg->data;
switch(((PortData *)incommingmsg->data)->PortStatus)
{
case PORT_STATUS_CONNECT:
ioprintf("\nc3Connect at Port c7 %sc3\n",cport2->clientconfig.IDNumber);
break;
case PORT_STATUS_LOGIN:
ioprintf("c3Login Sequence at Port c7 %sc3\n",cport2->clientconfig.IDNumber);
break;
case PORT_STATUS_ONLINE:
ioprintf("c3User: c7%s c3has login at Port c7 %dc3\n",cport2->LocalUser.Handle,cport2->clientconfig.IDNumber);
sprintf(buffer,"c3User: c7%s c3has login at Port c7 %dc3\n",cport2->LocalUser.Handle,cport2->clientconfig.IDNumber);
clientport=(PortData2 *)client_list->lh_Head;
while (clientport->port_node.ln_Succ)
{
cport2=clientport->port_address;
SendMsg(cport2->LocalPort,buffer,0,MSG_COMMAND,CMD_WHO);
clientport=(PortData2 *)clientport->port_node.ln_Succ;
}
break;
}
break;
case MSG_PORT_LOSTCARRIER:
cport2=(PortData *)incommingmsg->data;
ioprintf("c3User: c7%s c3has a lost carrier at Port c7 %dc3\n",cport2->LocalUser.Handle,cport2->clientconfig.IDNumber);
break;
case MSG_PORT_LOGOFF:
cport2=(PortData *)incommingmsg->data;
ioprintf("c3User: c7%s c3has logoff at Port c7 %dc3\n",cport2->LocalUser.Handle,cport2->clientconfig.IDNumber);
sprintf(buffer,"c3User: c7%s c3has logoff at Port c7 %dc3\n",cport2->LocalUser.Handle,cport2->clientconfig.IDNumber);
clientport=(PortData2 *)client_list->lh_Head;
while (clientport->port_node.ln_Succ)
{
cport2=clientport->port_address;
SendMsg(cport2->LocalPort,buffer,0,MSG_COMMAND,CMD_WHO);
clientport=(PortData2 *)clientport->port_node.ln_Succ;
}
break;
case MSG_PORT_RING:
cport2=(PortData *)incommingmsg->data;
ioprintf("c3RING Detected at Port c7 %dc3\n",cport2->clientconfig.IDNumber);
break;
case MSG_PORT_CID:
cport2=(PortData *)incommingmsg->data;
ioprintf("c3Telnet Connect at Port c7 %dc3\n",cport2->clientconfig.IDNumber);
break;
} // end switch
ReplyMsg((Message *)incommingmsg);
} // end id reply_message
} // end while getmsg
} // end test sigbit
}
/************** NFS Message Handling *************************************************************/
if (sb_nfs_port & sigs)
{
struct NFSPacket *packet;
while ((packet = (NFSPacket *)GetMsg(cport->nfs_port)))
{
if (packet->nfs_msg.mn_ReplyPort == cport->nfs_port)
{
if (packet->nfs_result1 == RESULT_NFS_TEXTNOTIFY)
if (packet->nfs_result2)
FreeVec(packet->nfs_result2);
FreeVec(packet);
}
else
{
if (packet->nfs_result1 == RESULT_NFS_TEXTNOTIFY)
{
if (packet->nfs_result2)
{
ioprintf("\n%s\n%d.%s:> ",packet->nfs_result2,cport->clientconfig.IDNumber,cport->currentdir->iib.fullpath);
}
ReplyMsg((Message *)packet);
}
}
}
}
/************** Commodities Message Handling *************************************************************/
if (sb_cxport & sigs)
{
struct Message *msg;
while ((msg = GetMsg(cxport)))
handleCxMsg(msg);
}
if (sigs & bitmask)Quit=TRUE;
}
}
return sigs;
}
BOOL SendMsg(MsgPort *port, APTR data, ULONG data_len, ULONG msg_type, ULONG cmd_type)
{
struct Task *mytask=FindTask(NULL);
struct PortData *cport=(PortData *)mytask->tc_UserData;
if (cport)
{
if (!(cport->LocalPort==port))
{
struct message *scheiss_telekom=MyAllocVec(sizeof(message),MEMF_ANY|MEMF_CLEAR,"IO_MAIN: SendMsg(), scheiss_telekom");
if (!scheiss_telekom)return FALSE;
if (port)
{
if (data_len>0)
{
scheiss_telekom->data=MyAllocVec(data_len,MEMF_ANY,"Main: SendMsg(), scheiss_telekom (message)");
if (scheiss_telekom->data==0)return FALSE;
CopyMem(data,scheiss_telekom->data,data_len);
}
else
{
scheiss_telekom->data=data;
}
scheiss_telekom->msg.mn_Length=sizeof(message)+data_len;
scheiss_telekom->msg.mn_ReplyPort=cport->LocalPort;
scheiss_telekom->IDNumber=0;
scheiss_telekom->IPNumber=cport->clientconfig.IDNumber;
scheiss_telekom->data_len=data_len;
scheiss_telekom->msg_type=msg_type;
scheiss_telekom->cmd_type=cmd_type;
scheiss_telekom->PortID=cport->clientconfig.IDNumber;
/* !!! Note are init by Alloc MEMF_CLEAR !!! */
// scheiss_telekom->ln_Pred=msg_list->last;
// scheiss_telekom->ln_Succ=0;
// msg_list->last->ln_Succ=scheiss_telekom;
// msg_list->last=scheiss_telekom;
PutMsg(port,(Message *)scheiss_telekom);
}
else
{
MyFreeVec(scheiss_telekom,"FREE IO_MAIN: scheiss_telekom");
return FALSE;
}
}
else
return FALSE;
}
else
return FALSE;
}
struct EventMessage *SendEventMsg(MsgPort *toport, MsgPort *replyport, APTR data, ULONG msg_type)
{
struct EventMessage *msg;
if ((msg=AllocVec(sizeof(EventMessage),MEMF_ANY|MEMF_CLEAR)))
{
msg->msg_type=msg_type;
msg->data=data;
msg->msg.mn_Length=sizeof(EventMessage);
msg->msg.mn_ReplyPort=replyport;
PutMsg(toport,(Message *)msg);
}
return msg;
}
LONG handleCxMsg(struct Message *msg)
{
LONG result = 0;
LONG msgid;
LONG msgtype;
msgid = CxMsgID((CxMsg *) msg );
msgtype = CxMsgType((CxMsg *) msg );
ReplyMsg(msg);
switch(msgtype)
{
case CXM_IEVENT:
switch(msgid)
{
case POP_KEY_ID:
Monitor_open();
break;
default:
break;
}
break;
case CXM_COMMAND:
switch(msgid)
{
case CXCMD_DISABLE:
ActivateCxObj(broker,0L);
break;
case CXCMD_ENABLE:
ActivateCxObj(broker,1L);
break;
case CXCMD_APPEAR: /* Time to pop up the window */
case CXCMD_UNIQUE: /* Someone has tried to run us again */
Monitor_open();
break; /* the window */
case CXCMD_DISAPPEAR:
Monitor_close();
break;
case CXCMD_KILL:
{
PortData *cport = (PortData *)FindTask(NULL)->tc_UserData;
cport->ProgramClose=TRUE;
cport->network.online = FALSE;
}
break;
default:
printf("cx.c: handleCxMsg(Custom Command)\n");
break;
} /* end switch(command) */
break;
} /* end switch(msgtype) */
return result;
}
void ioprintf(const char *string, ...)
{
char *buffer=AllocVec(10000,MEMF_ANY|MEMF_CLEAR);
if (buffer)
{
vsprintf(buffer, string, unsigned int(&string + 1));
Writeio(buffer,-1);
FreeVec(buffer);
}
}